#include "processbar.h"

typedef void (*callback_t)(int);

void download(callback_t cb)
{
    initbar();
    int total = 1024;
    int cur = 0;
    while (cur <= total)
    {
        usleep(50000);
        int rate = cur*100/total;
        cb(rate);
        if (rate == 99)
        {
            usleep(50000);
            cb(100);
            break;
        }
        cur += 10;
    }
    printf("\n");
}
int main()
{

    printf("download 1: \n");
    download(processbar);
    printf("download 2: \n");
    download(processbar);

    return 0;
}
